package com.example.yls.intent_service;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //启动服务
        findViewById(R.id.btn_start).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(MainActivity.this,MyFrontService.class);
                startService(intent);
            }
        });
        //启动Intent服务
        findViewById(R.id.btn_start_intent).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(MainActivity.this,MyIntentService.class);
                //下载音乐
                intent.putExtra("URL","http://www.baidu.com/hello.mp3");
                startService(intent);
            }
        });
    }
}
